package cn.net.mysoft.account.api.entity;

import cn.net.mysoft.account.api.common.AlgInNeed;

public class AccountEntity {
    int id;
    String userId;
    /**
     * type
     * 0 普通账户
     * 1 控制账户（余额对应的值为负值） 只能由后台管理人员创建
     */
    int type;
    long balance;
    String createTime;
    String modifyTime;
    int state;
    String remark;
    int ver;
    String sign;

    public int getVer() {
        return ver;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public void setVer(int ver) {
        this.ver = ver;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }

    public void setSign(){
        setSign(AlgInNeed.shaEncode(this.toSignString()));
    }

    public boolean isValid(){

        return this.sign.equalsIgnoreCase(AlgInNeed.shaEncode(this.toSignString()));
    }

    public String getSign() {
        return sign;
    }

    @Override
    public String toString() {
        return "AccountEntity{" +
                "id=" + id +
                ", userId='" + userId + '\'' +
                ", type=" + type +
                ", balance=" + balance +
                ", createTime='" + createTime + '\'' +
                ", modifyTime='" + modifyTime + '\'' +
                ", state=" + state +
                ", remark='" + remark + '\'' +
                ", sign='" + sign + '\'' +
                '}';
    }

    public String toSignString() {
        return "AccountEntity{" +
                "id=" + 0 +
                ", userId='" + userId + '\'' +
                ", type=" + type +
                ", balance=" + balance +
                ", createTime='" + createTime + '\'' +
                ", modifyTime='" + modifyTime + '\'' +
                ", state=" + state +
                ", remark='" + remark + '\'' +
                ", sign='"  + '\'' +
                '}';
    }

    public void setType(int type) {
        this.type = type;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public int getId() {
        return id;
    }

    public int getState() {
        return state;
    }

    public int getType() {
        return type;
    }

    public long getBalance() {
        return balance;
    }

    public String getCreateTime() {
        return createTime;
    }

    public String getModifyTime() {
        return modifyTime;
    }

    public String getUserId() {
        return userId;
    }

    public void setBalance(long balance) {
        this.balance = balance;
    }

    public void setModifyTime(String modify_time) {
        this.modifyTime = modify_time;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public void setState(int state) {
        this.state = state;
    }

    public void setUserid(String userid) {
        this.userId = userid;
    }

}
